<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<div class="easyui-layout" style="width:100%;height:100%;" fit="true">
    <div data-options="region:'center',title:'',split:true" style="height:100%;">
		<form id="drugBillInfo" method="post" >
			<input type="hidden" value="" name="productTypeId" >
			<table class="detailTable"  >
    	 	<tr>
                <th>分类名称:</th>
                <td>
                	<input class="easyui-validatebox"  name="productTypeName" data-options="required:true">
                </td>
            </tr>
            <tr>
                <th>分类拼音码:</th>
                <td><input class="easyui-validatebox "  name="spell" data-options="validType:'english'"></td>
            </tr>
            <tr>
                <th>父及分类:</th>
                <td>
                	<input class="easyui-combotree"  id="parentTypeId"  name="parentTypeId"  style="width: 250px;">
				</td>
            </tr>
            <tr>
                <th>分类顺序值:</th>
                <td><input class="easyui-numberspinner" name="sortOrder" style="width:80px;" value="10" required="required" data-options="min:10,max:1000,editable:true"></td>
            </tr>
			<tr>
				<td align="center" colspan="2">
					<input type="button" onclick="submitForm()" class="button" value="提交" >
					<input type="button" onclick="pms.resetForm('buyerAddInfo')" class="button" value="重置" >
				</td>
			</tr>
		</table>
		</form>
    </div>
</div>  
<script>


var flag="0";
$(function(){
	$("#parentTypeId").combotree({
		url:'<c:url value="/product/showEmBproductTypeList.do"/>?viewType=comboTree',
		method:'post',
		onLoadSuccess:function(){
			var pvalue = '${param.productTypeId}';
			if(pvalue!=""){
				flag = "1";
				var param = {"productTypeId":pvalue};
				$.pmsAjax({
					url : '<c:url value="/product/showEmBproductTypeDetail.do"/>',
					data : param,
					success : function(data) {
						if(data!=null){
							$('#drugBillInfo').form('load', data);
						}
					}
				});
			}
		}
	});
});
function submitForm(){
	$('#drugBillInfo').form('submit', {
	    url:'<c:url value="/product/saveOrUpdateEmBProductType.do"/>',
	    onSubmit: function(param){
	    	if(!$("#drugBillInfo").form('validate')){
	    		return false;
	    	}
	    	//时间对比
	    }, 
	    success:function(data){
		    var ret = eval("("+data+")")
	     	if(ret.code=="200"){
	     		if(flag == "0"){
	     			alertShow("新增分类成功!");
	     		}else{
	     			alertShow("修改分类成功");
	     		}
	     		$("#category_detail").dialog('close');
	     		initcategoryTableGrid();
		    }else{
		    	alertError(ret.result);
			}
	    }
	});
}
</script>
